<?php
# by A.E., returns the online-status from the poster, in messageview
function get_onlinestatus($username){
        global $prefix, $dbi, $cookie, $url_images, $HTTP_COOKIE_VARS;

        $result = sql_query("select uname from ".$prefix."_session where uname='$uname' LIMIT 0,1", $dbi);
        list($username) = sql_fetch_row($result, $dbi);
        if ($username == "" && $cookie[1]!=$username) {
                $online = _PMSOFFLINE;
                $img = "$url_images/td.gif";
                }
        else {
                $online = _PMSONLINE;
                $img = "$url_images/tu.gif";
                }
        return "<br><img src=\"$img\" alt=\"$online\" width=\"10\" height=\"10\" border=\"0\">&nbsp;$online\n";
        }

######################################################################
function get_userdata_from_id($userid) {
  global $user_prefix, $dbi;
  $sql = "SELECT * FROM ".$user_prefix."_users WHERE user_id = $userid";
  if(!$result = sql_query($sql, $dbi)) {
          $userdata = array("error" => "1");
          return ($userdata);
          }
  if(!$myrow = sql_fetch_array($result, $dbi)) {
          $userdata = array("error" => "1");
          return ($userdata);
          }
  return($myrow);
        }

######################################################################
/*
 * Changes :) to an <IMG> tag based on the smiles table in the database.
 * Smilies must be either:
 *   - at the start of the message.
 *   - at the start of a line.
 *   - preceded by a space or a period.
 * This keeps them from breaking HTML code and BBCode.
 * TODO: Get rid of global variables.
 */
function smile($message) {
        global $url_smiles, $smilie;
        $message = " " . $message;  // Pad it with a space so the regexp can match.
        asort($smilie);
        while(list($key, $val) = each($smilie)) {
                $vals=explode(",",$val);
                $smile_code = preg_quote($vals[0]);
                $smile_code = str_replace('/', '//', $smile_code);
                $message = preg_replace("/([\n\\ \\.])$smile_code/si", '\1<IMG SRC="' . $url_smiles . '/' . $vals[2] . '">', $message);
                }
        // Remove padding, return the new string.
        $message = substr($message, 1);
        return($message);
        }

######################################################################
/*
 * Changes a Smiliy <IMG> tag into its corresponding smile
 * TODO: Get rid of golbal variables, and implement a method of distinguishing between :D and :grin: using the <IMG> tag
 */
function desmile($message) {
        // Ick Ick Global variables...remind me to fix these! - theFinn
        global $url_smiles, $smilie;
        asort($smilie);
        while(list($key, $val) = each($smilie)) {
                $vals=explode(",",$val);
                $smile_code = preg_quote($vals[0]);
                $smile_code = str_replace('/', '//', $smile_code);
                $message = str_replace(" <IMG SRC=\"$url_smiles/".$vals[2]."\"> ", $smile_code, $message);
                }
        return($message);
        }


######################################################################
function bbencode($message) {
  global $prefix, $dbi;
  // [CODE] and [/CODE] for posting code (HTML, PHP, C etc etc) in your posts.
  $matchCount = preg_match_all("#\[code\](.*?)\[/code\]#si", $message, $matches);
  for ($i = 0; $i < $matchCount; $i++)  {
    $currMatchTextBefore = preg_quote($matches[1][$i]);
    $currMatchTextAfter = htmlspecialchars($matches[1][$i]);
    $message = preg_replace("#\[code\]$currMatchTextBefore\[/code\]#si", "<!-- BBCode Start --><TABLE BORDER=\"0\" ALIGN=\"CENTER\" WIDTH=\"85%\"><TR><TD><font class=\"tiny\">Code:</font><hr size=1 noshade></TD></TR><TR><TD><font class=\"tiny\"><PRE>$currMatchTextAfter</PRE></FONT></TD></TR><TR><TD><hr size=1 noshade></TD></TR></TABLE><!-- BBCode End -->", $message);
          }
  // [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff.
  $message = preg_replace("#\[quote\](.*?)\[/quote]#si", "<!-- BBCode Quote Start --><TABLE BORDER=\"0\" ALIGN=\"CENTER\" WIDTH=\"85%\"><TR><TD><font class=\"tiny\">Quote:</font><hr size=1 noshade></TD></TR><TR><TD><BLOCKQUOTE><font class=\"tiny\">\\1</FONT></BLOCKQUOTE></TD></TR><TR><TD><hr size=1 noshade></TD></TR></TABLE><!-- BBCode Quote End -->", $message);
  // [b] and [/b] for bolding text.
  $message = preg_replace("#\[b\](.*?)\[/b\]#si", "<!-- BBCode Start --><B>\\1</B><!-- BBCode End -->", $message);
  // [i] and [/i] for italicizing text.
  $message = preg_replace("#\[i\](.*?)\[/i\]#si", "<!-- BBCode Start --><I>\\1</I><!-- BBCode End -->", $message);
  // [url]www.phpbb.com[/url] code..
  $message = preg_replace("#\[url\](http://)?(.*?)\[/url\]#si", "<!-- BBCode Start --><A HREF=\"http://\\2\" TARGET=\"_blank\">\\2</A><!-- BBCode End -->", $message);
  // [url=www.phpbb.com]phpBB[/url] code..
  $message = preg_replace("#\[url=(http://)?(.*?)\](.*?)\[/url\]#si", "<!-- BBCode Start --><A HREF=\"http://\\2\" TARGET=\"_blank\">\\3</A><!-- BBCode End -->", $message);
  // [email]user@domain.tld[/email] code..
  $message = preg_replace("#\[email\](.*?)\[/email\]#si", "<!-- BBCode Start --><A HREF=\"mailto:\\1\">\\1</A><!-- BBCode End -->", $message);
  // [img]image_url_here[/img] code..
  $message = preg_replace("#\[img\](.*?)\[/img\]#si", "<!-- BBCode Start --><IMG SRC=\"\\1\"><!-- BBCode End -->", $message);
  // unordered list code..
  $matchCount = preg_match_all("#\[list\](.*?)\[/list\]#si", $message, $matches);
  for ($i = 0; $i < $matchCount; $i++)  {
    $currMatchTextBefore = preg_quote($matches[1][$i]);
    $currMatchTextAfter = preg_replace("#\[\*\]#si", "<LI>", $matches[1][$i]);
    $message = preg_replace("#\[list\]$currMatchTextBefore\[/list\]#si", "<!-- BBCode ulist Start --><UL>$currMatchTextAfter</UL><!-- BBCode ulist End -->", $message);
          }
  // ordered list code..
  $matchCount = preg_match_all("#\[list=([a1])\](.*?)\[/list\]#si", $message, $matches);
  for ($i = 0; $i < $matchCount; $i++)  {
    $currMatchTextBefore = preg_quote($matches[2][$i]);
    $currMatchTextAfter = preg_replace("#\[\*\]#si", "<LI>", $matches[2][$i]);
    $message = preg_replace("#\[list=([a1])\]$currMatchTextBefore\[/list\]#si", "<!-- BBCode olist Start --><OL TYPE=\\1>$currMatchTextAfter</OL><!-- BBCode olist End -->", $message);
          }
  return($message);
        }

######################################################################
function bbdecode($message) {
        // Undo [code]
        #$code_start_html = "<!-- BBCode Start --><TABLE BORDER=\"0\" ALIGN=\"CENTER\" WIDTH=\"85%\"><TR><TD><font class=\"tiny\">Code:</font><hr size=1 noshade></TD></TR><TR><TD><font class=\"tiny\"><PRE>";
        #$code_end_html = "</PRE></FONT></TD></TR><TR><TD><hr size=1 noshade></TD></TR></TABLE><!-- BBCode End -->";
        #$message = str_replace($code_start_html, "[code]", $message);
        #$message = str_replace($code_end_html, "[/code]", $message);
        // Undo [quote]
        $quote_start_html = "<!-- BBCode Quote Start --><TABLE BORDER=\"0\" ALIGN=\"CENTER\" WIDTH=\"85%\"><TR><TD><font class=\"tiny\">Quote:</font><hr size=1 noshade></TD></TR><TR><TD><BLOCKQUOTE><font class=\"tiny\">";
        $quote_end_html = "</FONT></BLOCKQUOTE></TD></TR><TR><TD><hr size=1 noshade></TD></TR></TABLE><!-- BBCode Quote End -->";
        $message = str_replace($quote_start_html, "[quote]", $message);
        $message = str_replace($quote_end_html, "[/quote]", $message);
        // Undo [b] and [i]
        $message = preg_replace("#<!-- BBCode Start --><B>(.*?)</B><!-- BBCode End -->#s", "[b]\\1[/b]", $message);
        $message = preg_replace("#<!-- BBCode Start --><I>(.*?)</I><!-- BBCode End -->#s", "[i]\\1[/i]", $message);
        // Undo [url] (long form)
        $message = preg_replace("#<!-- BBCode u2 Start --><A HREF=\"([a-z]+?://)(.*?)\" TARGET=\"_blank\">(.*?)</A><!-- BBCode u2 End -->#s", "[url=\\1\\2]\\3[/url]", $message);
        // Undo [url] (short form)
        $message = preg_replace("#<!-- BBCode u1 Start --><A HREF=\"([a-z]+?://)(.*?)\" TARGET=\"_blank\">(.*?)</A><!-- BBCode u1 End -->#s", "[url]\\3[/url]", $message);
        // Undo [email]
        $message = preg_replace("#<!-- BBCode Start --><A HREF=\"mailto:(.*?)\">(.*?)</A><!-- BBCode End -->#s", "[email]\\1[/email]", $message);
        // Undo [img]
        $message = preg_replace("#<!-- BBCode Start --><IMG SRC=\"(.*?)\" BORDER=\"0\"><!-- BBCode End -->#s", "[img]\\1[/img]", $message);
        // Undo lists (unordered/ordered)
        // <li> tags:
        $message = str_replace("<!-- BBCode --><LI>", "[*]", $message);
        // [list] tags:
        $message = str_replace("<!-- BBCode ulist Start --><UL>", "[list]", $message);
        // [list=x] tags:
        $message = preg_replace("#<!-- BBCode olist Start --><OL TYPE=([A1])>#si", "[list=\\1]", $message);
        // [/list] tags:
        $message = str_replace("</UL><!-- BBCode ulist End -->", "[/list]", $message);
        $message = str_replace("</OL><!-- BBCode olist End -->", "[/list]", $message);
        return($message);
        }

######################################################################
/**
 * Nathan Codding - Jan. 12, 2001.
 * Performs [quote][/quote] bbencoding on the given string, and returns the results.
 * Any unmatched "[quote]" or "[/quote]" token will just be left alone.
 * This works fine with both having more than one quote in a message, and with nested quotes.
 * Since that is not a regular language, this is actually a PDA and uses a stack. Great fun.
 *
 * Note: This function assumes the first character of $message is a space, which is added by
 * bbencode().
 */
function bbencode_quote($message){
  // First things first: If there aren't any "[quote]" strings in the message, we don't
  // need to process it at all.
  if (!strpos(strtolower($message), "[quote]"))  {
    return $message;
          }
  $stack = Array();
  $curr_pos = 1;
  while ($curr_pos && ($curr_pos < strlen($message)))  {
    $curr_pos = strpos($message, "[", $curr_pos);
    // If not found, $curr_pos will be 0, and the loop will end.
    if ($curr_pos)    {
      // We found a [. It starts at $curr_pos.
      // check if it's a starting or ending quote tag.
      $possible_start = substr($message, $curr_pos, 7);
      $possible_end = substr($message, $curr_pos, 8);
      if (strcasecmp("[quote]", $possible_start) == 0)      {
        // We have a starting quote tag.
        // Push its position on to the stack, and then keep going to the right.
        array_push($stack, $curr_pos); #bbcode_array_push($stack, $curr_pos);
        ++$curr_pos;
              }
      else if (strcasecmp("[/quote]", $possible_end) == 0)      {
        // We have an ending quote tag.
        // Check if we've already found a matching starting tag.
        if (sizeof($stack) > 0)        {
          // There exists a starting tag.
          // We need to do 2 replacements now.
          $start_index = array_pop($stack); #bbcode_array_pop($stack);
          // everything before the [quote] tag.
          $before_start_tag = substr($message, 0, $start_index);
          // everything after the [quote] tag, but before the [/quote] tag.
          $between_tags = substr($message, $start_index + 7, $curr_pos - $start_index - 7);
          // everything after the [/quote] tag.
          $after_end_tag = substr($message, $curr_pos + 8);
          $message = $before_start_tag . "<!-- BBCode Quote Start --><TABLE BORDER=\"0\" ALIGN=\"CENTER\" WIDTH=\"85%\"><TR><TD><font class=\"tiny\">Quote:</font><hr size=1 noshade></TD></TR><TR><TD><BLOCKQUOTE><font class=\"tiny\">";
          $message .= $between_tags . "</FONT></BLOCKQUOTE></TD></TR><TR><TD><hr size=1 noshade></TD></TR></TABLE><!-- BBCode Quote End -->";
          $message .= $after_end_tag;
          // Now.. we've screwed up the indices by changing the length of the string.
          // So, if there's anything in the stack, we want to resume searching just after it.
          // otherwise, we go back to the start.
          if (sizeof($stack) > 0)          {
            $curr_pos = array_pop($stack); #bbcode_array_pop($stack);
            array_push($stack, $curr_pos); #bbcode_array_push($stack, $curr_pos);
            ++$curr_pos;
                  }
          else          {
            $curr_pos = 1;
                  }
                }
        else        {// No matching start tag found. Increment pos, keep going.
          ++$curr_pos;
                }
              }
      else      {// No starting tag or ending tag.. Increment pos, keep looping.,
        ++$curr_pos;
              }
            }
          } // while
  return $message;
        } // bbencode_quote()

######################################################################
/**
 * Nathan Codding - Oct. 30, 2000
 *
 * Escapes the "/" character with "\/". This is useful when you need
 * to stick a runtime string into a PREG regexp that is being delimited
 * with slashes.
 */
function escape_slashes($input){
  $output = str_replace('/', '\/', $input);
  return $output;
        }

######################################################################
/**
 * Rewritten by Nathan Codding - Feb 6, 2001.
 * - Goes through the given string, and replaces xxxx://yyyy with an HTML <a> tag linking
 *   to that URL
 * - Goes through the given string, and replaces www.xxxx.yyyy[zzzz] with an HTML <a> tag linking
 *   to http://www.xxxx.yyyy[/zzzz]
 * - Goes through the given string, and replaces xxxx@yyyy with an HTML mailto: tag linking
 *    to that email address
 * - Only matches these 2 patterns either after a space, or at the beginning of a line
 * Notes: the email one might get annoying - it's easy to make it more restrictive, though.. maybe
 * have it require something like xxxx@yyyy.zzzz or such. We'll see.
 */
function make_clickable($text) {
  // pad it with a space so we can match things at the start of the 1st line.
  $ret = " " . $text;
  // matches an "xxxx://yyyy" URL at the start of a line, or after a space.
  // xxxx can only be alpha characters.
  // yyyy is anything up to the first space, newline, or comma.
  $ret = preg_replace("#([\n ])([a-z]+?)://([^, \n\r]+)#i", "\\1<!-- BBCode auto-link start --><a href=\"\\2://\\3\" target=\"_blank\">\\2://\\3</a><!-- BBCode auto-link end -->", $ret);
  // matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
  // Must contain at least 2 dots. xxxx contains either alphanum, or "-"
  // yyyy contains either alphanum, "-", or "."
  // zzzz is optional.. will contain everything up to the first space, newline, or comma.
  // This is slightly restrictive - it's not going to match stuff like "forums.foo.com"
  // This is to keep it from getting annoying and matching stuff that's not meant to be a link.
  $ret = preg_replace("#([\n ])www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[^, \n\r]*)?)#i", "\\1<!-- BBCode auto-link start --><a href=\"http://www.\\2.\\3\\4\" target=\"_blank\">www.\\2.\\3\\4</a><!-- BBCode auto-link end -->", $ret);
  // matches an email@domain type address at the start of a line, or after a space.
  // Note: before the @ sign, the only valid characters are the alphanums and "-", "_", or ".".
  // After the @ sign, we accept anything up to the first space, linebreak, or comma.
  $ret = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([^, \n\r]+)#i", "\\1<!-- BBcode auto-mailto start --><a href=\"mailto:\\2@\\3\">\\2@\\3</a><!-- BBCode auto-mailto end -->", $ret);
  // Remove our padding..
  $ret = substr($ret, 1);
  return($ret);
        }

######################################################################
/**
 * Nathan Codding - Feb 6, 2001
 * Reverses the effects of make_clickable(), for use in editpost.
 * - Does not distinguish between "www.xxxx.yyyy" and "http://aaaa.bbbb" type URLs.
 */
function undo_make_clickable($text) {
  $text = preg_replace("#<!-- BBCode auto-link start --><a href=\"(.*?)\" target=\"_blank\">.*?</a><!-- BBCode auto-link end -->#i", "\\1", $text);
  $text = preg_replace("#<!-- BBcode auto-mailto start --><a href=\"mailto:(.*?)\">.*?</a><!-- BBCode auto-mailto end -->#i", "\\1", $text);
  return $text;
        }

######################################################################
/**
 * Nathan Codding - August 24, 2000.
 * Takes a string, and does the reverse of the PHP standard function
 * htmlspecialchars().
 */
function undo_htmlspecialchars($input) {
  $input = preg_replace("/&gt;/i", ">", $input);
  $input = preg_replace("/&lt;/i", "<", $input);
  $input = preg_replace("/&quot;/i", "\"", $input);
  $input = preg_replace("/&amp;/i", "&", $input);
  return $input;
        }

######################################################################
function printsmilies(){
  global $url_smiles, $smilie;
        $cols=3;
        $count=0;
        asort($smilie);
        $break=(sizeof($smilie)/$cols);
        $rowspan=$cols+1;
        $colspan=$break+1;
        echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"2\" width=\"120\">
        <tr><td rowspan=\"$colspan\" width=\"1\"></td><td colspan=\"$rowspan\"><font class=\"tiny\">"._PMSCLICKSMILEBUTTONS."</font></td></tr>
        <tr valign=\"top\"><td>";
        while(list($key, $val) = each($smilie)) {
                $count++;
                $vals=explode(",",$val);
                $size=@getimagesize("$url_smiles/$vals[2]");
                $size=$size[3];
                echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' $vals[0] ');\"><IMG src=\"$url_smiles/$vals[2]\" border=\"0\" $size alt=\"$vals[1] $vals[0]\" vspace=\"3\"></A><br>\n";
                if (($count>=$break) && $count<sizeof($smilie)){
                        echo "</td><td>";
                        $break=$break+$count;
                        #$count=0;
                        }
                }
        echo "</td></tr></table>";
        }

######################################################################
function printbuddysmilies(){
  global $url_smiles, $smilie;
        $cols=1;
        $count=0;
        asort($smilie);
        $break=(sizeof($smilie)/$cols);
        while(list($key, $val) = each($smilie)) {
                $count++;
                $vals=explode(",",$val);
                $size=@getimagesize("$url_smiles/$vals[2]");
                $size=$size[3];
                echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' $vals[0] ');\"><IMG src=\"$url_smiles/$vals[2]\" border=\"0\" $size alt=\"$vals[1] $vals[0]\" vspace=\"3\"></A> \n";
                if (($count>=$break) && $count<sizeof($smilie)){
                        echo "<br>";
                        $break=$break+$count;
                        }
                }
        }

######################################################################
function putitems() {
  global $prefix, $dbi, $url_images;
        echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\"><tr>";
        echo "<td><A href=\"javascript: x()\" onClick=\"DoPrompt('url');\"><IMG src=\"$url_images/bb_url.gif\" border=\"0\" alt=\"BBCode: Web Address\"></a></td>";
  echo "<td><A href=\"javascript: x()\" onClick=\"DoPrompt('email');\"><IMG src=\"$url_images/bb_email.gif\" border=\"0\" alt=\"BBCode: Email Address\"></a></td>";
  echo "<td><A href=\"javascript: x()\" onClick=\"DoPrompt('image');\"><IMG src=\"$url_images/bb_image.gif\" border=\"0\" alt=\"BBCode: Load Image from Web\"></a></td>";
  echo "<td><A href=\"javascript: x()\" onClick=\"DoPrompt('bold');\"><IMG src=\"$url_images/bb_bold.gif\" border=\"0\" alt=\"BBCode: Bold Text\"></a></td>";
  echo "<td><A href=\"javascript: x()\" onClick=\"DoPrompt('italic');\"><IMG src=\"$url_images/bb_italicize.gif\" border=\"0\" alt=\"BBCode: Italic Text\"></a></td>";
  echo "<td><A href=\"javascript: x()\" onClick=\"DoPrompt('quote');\"><IMG src=\"$url_images/bb_quote.gif\" border=\"0\" alt=\"BBCode: Quote\"></a></td>";
  #echo "<td><A href=\"javascript: x()\" onClick=\"DoPrompt('code');\"><IMG src=\"$url_images/bb_code.gif\" border=\"0\" alt=\"BBCode: Code\"></a></td>";
  #echo "<td><A href=\"javascript: x()\" onClick=\"DoPrompt('listopen');\"><IMG src=\"$url_images/bb_listopen.gif\" border=\"0\" alt=\"BBCode: Open List\"></a></td>";
  #echo "<td><A href=\"javascript: x()\" onClick=\"DoPrompt('listitem');\"><IMG src=\"$url_images/bb_listitem.gif\" border=\"0\" alt=\"BBCode: List Item\"></a></td>";
  #echo "<td><A href=\"javascript: x()\" onClick=\"DoPrompt('listclose');\"><IMG src=\"$url_images/bb_listclose.gif\" border=\"0\" alt=\"BBCode: Close List\"></a></td>";
  echo "</tr></table><font class=\"tiny\">"._PMSCLICKCODEBUTTONS."</font><br>";
        }

#########################################################################################
function valueToText($tmp) {
  $tmp = ereg_replace(10,"",$tmp);
  $tmp = ereg_replace(9,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;",$tmp);
  $tmp = ereg_replace("<","&lt;",$tmp);
  $tmp = ereg_replace(">","&gt;",$tmp);
  $tmp = ereg_replace("\"","&quot;",$tmp);
  //$tmp = str_replace("\\","\\\\",$tmp);
  $tmp = ereg_replace("'","`",$tmp);
  #$tmp = ereg_replace(13,"<br>",$tmp);
  $tmp = ereg_replace(13," ",$tmp);
        $tmp=nl2br($tmp);
  return $tmp;
        }

#########################################################################################
function loadindexjavascript() {
        global $bgcolor1, $bgcolor2, $bgcolor3, $textcolor1, $textcolor2, $popupwidth, $poptableborder, $module_name;
                        echo "<style type=\"text/css\">
                                .listpopup {
                                        position:absolute;
                                        top: 12000px;
                                        left: 12000px;
                                        width: ${popupwidth}px;
                                        height: auto;
                                        layer-background-color:$bgcolor2;
                                        border: ${poptableborder}px inset $bgcolor1;
                                        visibility:hidden;
                                        background : $bgcolor2;
                                        z-index : 200;
                                        text-decoration : none;
                                        color : $textcolor2;
                                        padding : 4 2 2 4;
                                        margin : 4;
                                        overflow : hidden;
                                        font-size : 9px;
                                        font-weight : lighter;
                                }
</style>";

        echo "
<script language=\"javascript1.2\" type=\"text/javascript\">
<!-- // some known objects
var nc                =        !!(document.captureEvents        &&        !document.getElementById);
var nc6                 =        !!(document.captureEvents        &&        document.documentElement);
var opera        =        !!(document.getElementById        &&        !document.documentElement);
var ie                =        !!document.all;
var ie4                 =        !!(document.all                                &&        !document.documentElement);
var ie5                 =        !!(document.all                                &&        document.documentElement);
var dom                 =        !!document.getElementById;
var aktDiv  =   false;
function layS(num){
        return (nc? document.layers[num]:(ie4? document.all[num].style:document.getElementById(num).style));
        }
function on(num){
        aktDiv = num;
        layS(num).visibility = \"visible\";
        }
function off(num){
        aktDiv = false;
        layS(num).visibility=\"hidden\";
        }
function divEvent() {
        if(nc) document.captureEvents(Event.MOUSEMOVE);
        document.onmousemove = divPos;
        }
function divPos(e) {
        yPos = (nc || nc6)? e.pageY : window.event.y;
        xPos = (nc || nc6)? e.pageX : window.event.x;
        if(aktDiv){
                layS(aktDiv).left = xPos + 5;
                layS(aktDiv).top = yPos + 5;
                }
        }
function CheckAll() {
        for (var i=0;i<document.prvmsg.elements.length;i++) {
                var e = document.prvmsg.elements[i];
                if ((e.name != 'allbox') && (e.type=='checkbox'))
                        e.checked = document.prvmsg.allbox.checked;
                        }
                }
function CheckCheckAll() {
        var TotalBoxes = 0;
        var TotalOn = 0;
        for (var i=0;i<document.prvmsg.elements.length;i++) {
                var e = document.prvmsg.elements[i];
                if ((e.name != 'allbox') && (e.type=='checkbox')) {
                        TotalBoxes++;
                        if (e.checked) {
                                TotalOn++;
                                }
                        }
                }
        if (TotalBoxes==TotalOn) {
                document.prvmsg.allbox.checked=true;
                }
        else {
                document.prvmsg.allbox.checked=false;
                }
        }
//-->
</script>\n";
        }
?>